<!DOCTYPE html>
<!-- 级联下拉框 -->
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(function() {
	$.get("../CityServlet",{method:"list"},function(data){
		
		for(var i=0;i<data.length;i++){
			$("#city").append("<option value='"+data[i].cityCode+"'>"+data[i].cityName+"</option>");
		}
	},"json");
	$("#city").change(function(data){
		$.getJSON("../BranchServlet",{cityCode:$("#city").val(),method:"list"},function(data){
			//删除Select中索引值大于0的元素
			$("#branch option:gt(0)").remove(); 
			for(var i=0;i<data.length;i++){
				$("#branch").append("<option value='"+data[i].branchCode+"'>"+data[i].branchName+"</option>");
			}
		});
	});
	$("#branch").change(function(data) {
		$.getJSON("../StaffServlet",{branchCode:$("#branch").val,method:"list"},function(data){
			$("#staff option:gt(0)").remove();
			for(var i=0;i<data.length;i++){
				$("#staff").append("<option value='"+data[i].staffCode+"'>"+data[i].staffName+"</option>");
			}
		});
	});
})
</script>
</head>
<body>
 城市：<select id="city">
		<option value="">请选择</option>
	</select>
   部门：<select id="branch">
		<option value="">请选择</option>
	</select>
   员工：<select id="staff">
		<option value="">请选择</option>
	</select>
</body>
</html>